package com.mijie.homi.dao.user;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.user.DeviceInfo;

@Repository
public class DeviceInfoDao extends IBatisDao {

	public int addOrUpdateDeviceInfo(DeviceInfo device){
		return this.insert("addOrUpdateDeviceInfo", device);
	}
	
	public DeviceInfo getDeviceInfo(String deviceId){
		return this.selectOne("getDeviceInfo", deviceId);
	}
	
	public List<DeviceInfo> listIOSDevice(int offset,int limit){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return this.selectList("listIOSDevice", parameter);
	}
	
	public int updateNotifyUpdateAt(String deviceId,Date recentNotifyUpgradeAt){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("recentNotifyUpgradeAt", recentNotifyUpgradeAt);
		parameter.put("deviceId", deviceId);
		return this.update("updateNotifyUpdateAt", parameter);
	}
	
	public int updateNotifyLoginAt(String deviceId,Date recentNotifyLoginAt){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("recentNotifyLoginAt", recentNotifyLoginAt);
		parameter.put("deviceId", deviceId);
		return this.update("updateNotifyLoginAt", parameter);
	}
	
	public int incrDeviceUnreadNotifyCount(String deviceId,int num){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("num", num);
		parameter.put("deviceId", deviceId);
		return this.update("incrDeviceUnreadNotifyCount", parameter);
	}
}
